﻿using AntDesign;
using Blazor.Core.Exceptions;

namespace Blazor.Core.Extensions;

public static class ConfigurationExtensions
{
    public static T GetTyped<T>(this IConfiguration configuration, string? path = null)
    {
        if (!string.IsNullOrWhiteSpace(path))
        {
            configuration = configuration.GetSection(path);
        }

        return configuration.Get<T>() ?? throw new ConfigurationParseException();
    }
}